package view.views;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;

import javax.swing.BoxLayout;
import javax.swing.JButton;

import model.HostAddress;
import model.IPAddress;
import model.Subnet;
import view.ToolBar;
import view.components.IpAddressTable;
import view.components.NetworkTree;
import view.listeners.TreeListener;
import controller.Controller;

public class TreeTablePanelView extends DefaultContentPanelView {
	private IpAddressTable table;
	private NetworkTree tree;
	private static final long serialVersionUID = 1L;
	final static String Panel_Name = "Übersicht";

	public TreeTablePanelView() {

		this.setName(Panel_Name);
	}

	@Override
	public void load() {
		this.removeAll();
		this.setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));

		ToolBar toolBar = Controller.getInstance().getGuiBuilder().getToolBar();

		tree = new NetworkTree();
		table = new IpAddressTable();
		tree.setIpAddressTable(table);
		
		MouseListener listener = new MouseListener() {
			
			@Override
			public void mouseReleased(MouseEvent arg0) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void mousePressed(MouseEvent arg0) {
				tree.removeRow();
				
			}
			
			@Override
			public void mouseExited(MouseEvent arg0) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void mouseEntered(MouseEvent arg0) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void mouseClicked(MouseEvent arg0) {
				// TODO Auto-generated method stub
				
			}
		};

		toolBar.addButton("add.png", null, "Hinzufügen");
		toolBar.addButton("delete.png", listener, "Löschen");
		this.add(tree);
		this.add(table);

	}

	public IpAddressTable getTable() {
		return table;
	}

}
